return gtk_css_node_get_style (context->priv->cssnode);
}
-static GtkCssStyle *
-gtk_style_context_lookup_style_for_state (GtkStyleContext *context,
- GtkStateFlags state)
+static GtkStateFlags
+gtk_style_context_push_state (GtkStyleContext *context,
+ GtkStateFlags state)
{
- GtkCssNode *node;
- GtkCssStyle *values;
+ GtkStateFlags current_state;
+
+ current_state = gtk_css_node_get_state (context->priv->cssnode);
- if (gtk_css_node_get_state (context->priv->cssnode) == state)
- return g_object_ref (gtk_style_context_lookup_style (context));
+ if (current_state == state)
+ return state;
if (g_getenv ("GTK_STYLE_CONTEXT_WARNING"))
{
}
}
- node = gtk_css_transient_node_new (context->priv->cssnode);
- gtk_css_node_set_parent (node, gtk_css_node_get_parent (context->priv->cssnode));
- gtk_css_node_set_state (node, state);
- values = g_object_ref (gtk_css_node_get_style (node));
- gtk_css_node_set_parent (node, NULL);
- g_object_unref (node);
+ gtk_css_node_set_state (context->priv->cssnode, state);
- return values;
+ return current_state;
+}
+
+static void
+gtk_style_context_pop_state (GtkStyleContext *context,
+ GtkStateFlags saved_state)
+{
+ gtk_css_node_set_state (context->priv->cssnode, saved_state);
}
/**
GtkStateFlags state,
GValue *value)
{
- GtkCssStyle *values;
+ GtkStateFlags saved_state;
GtkStyleProperty *prop;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
return;
}
- values = gtk_style_context_lookup_style_for_state (context, state);
- _gtk_style_property_query (prop, value, gtk_style_context_query_func, values);
- g_object_unref (values);
+ saved_state = gtk_style_context_push_state (context, state);
+ _gtk_style_property_query (prop,
+ value,
+ gtk_style_context_query_func,
+ gtk_css_node_get_style (context->priv->cssnode));
+ gtk_style_context_pop_state (context, saved_state);
}
/**
GtkBorder *border)
{
GtkCssStyle *style;
+ GtkStateFlags saved_state;
double top, left, bottom, right;
g_return_if_fail (border != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- style = gtk_style_context_lookup_style_for_state (context, state);
+ saved_state = gtk_style_context_push_state (context, state);
+ style = gtk_style_context_lookup_style (context);
top = round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_TOP_WIDTH), 100));
right = round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH), 100));
border->bottom = bottom;
border->right = right;
- g_object_unref (style);
+ gtk_style_context_pop_state (context, saved_state);
}
/**
GtkBorder *padding)
{
GtkCssStyle *style;
+ GtkStateFlags saved_state;
double top, left, bottom, right;
g_return_if_fail (padding != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- style = gtk_style_context_lookup_style_for_state (context, state);
+ saved_state = gtk_style_context_push_state (context, state);
+ style = gtk_style_context_lookup_style (context);
top = round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_TOP), 100));
right = round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_PADDING_RIGHT), 100));
padding->bottom = bottom;
padding->right = right;
- g_object_unref (style);
+ gtk_style_context_pop_state (context, saved_state);
}
/**
GtkBorder *margin)
{
GtkCssStyle *style;
+ GtkStateFlags saved_state;
double top, left, bottom, right;
g_return_if_fail (margin != NULL);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- style = gtk_style_context_lookup_style_for_state (context, state);
+ saved_state = gtk_style_context_push_state (context, state);
+ style = gtk_style_context_lookup_style (context);
top = round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_TOP), 100));
right = round (_gtk_css_number_value_get (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_MARGIN_RIGHT), 100));
margin->bottom = bottom;
margin->right = right;
- g_object_unref (style);
+ gtk_style_context_pop_state (context, saved_state);
}
/**